\testfile{pgfplotstest.ticks.tex}
\testsection{Minor ticks}
\starttikzpicture
\startaxis[minor tick num=3]
\smallplotstest
\stopaxis
\stoptikzpicture
%\endinput
\starttikzpicture
\startaxis[minor tick num=1]
\smallplotstest
\stopaxis
\stoptikzpicture

\starttikzpicture
\startaxis[minor tick num=5]
\smallplotstest
\stopaxis
\stoptikzpicture

\starttikzpicture
%\tracingmacros=2\tracingcommands=2
\startaxis[minor tick num=5,xtick={0.5,1,2,2.5,3}]
\smallplotstest
\stopaxis
%\tracingmacros=0\tracingcommands=0
\stoptikzpicture

\testsection{Tick placement}
\starttikzpicture
\startaxis[
	xtick={-1.5,-1,...,1.5},
	ytick={-0.5,0,...,1.5},
	]
\smallplotstest
\stopaxis
\stoptikzpicture

\starttikzpicture
\startaxis[
	xmin=0,xmax=1,
	xtick={-1.5,-1.25,...,1.5}]
\smallplotstest
\stopaxis
\stoptikzpicture

\testsubsection{xtick=data}
\starttikzpicture
\startaxis[xtick=data,xmajorgrids]
\addplot coordinates {(0,0) (0.4,1) (1,2) (1.2,3) (4,5)};
\stopaxis
\stoptikzpicture

\starttikzpicture
\startaxis[xtick=data,xmajorgrids]
\addplot coordinates {(0,0) (0.4,1) (1,2) (1.2,3) (4,5)};
\addplot coordinates {(0.1,1) (0.5,2) (1.2,3)};
\stopaxis
\stoptikzpicture

\starttikzpicture
\startloglogaxis[xtick=data,xmajorgrids]
\loglogtestplot
\stoploglogaxis
\stoptikzpicture

\testsubsubsection{ytick=data}
\starttikzpicture
\startaxis[ytick=data,ymajorgrids]
\addplot coordinates {(0,0) (0.4,1) (1,2) (1.2,3) (4,5)};
\addplot coordinates {(0.1,1) (0.5,2) (1.2,3)};
\stopaxis
\stoptikzpicture

\starttikzpicture
\startloglogaxis[ytick=data,ymajorgrids]
\loglogtestplot
\stoploglogaxis
\stoptikzpicture

\testsubsection{ticks on axis rectangle}
First plot: default tick style; second plot: red, third: 'help lines'

{\pgfplotsset{every axis/.append style={
	enlargelimits=false,
	xmin=-40,xmax=40,ymin=-40,ymax=40,
	xtick={-40,0,40},
	ytick={-40,0,40}
}}%
\starttikzpicture
\startaxis[
]
\addplot coordinates {(-40,-40) (40,40)};
\stopaxis
\stoptikzpicture
\starttikzpicture
\startaxis[
	tick style={red,line width=5pt,major tick length=20pt},
]
\addplot coordinates {(-40,-40) (40,40)};
\stopaxis
\stoptikzpicture
\starttikzpicture
\startaxis[
	tick style={help lines},
]
\addplot coordinates {(-40,-40) (40,40)};
\stopaxis
\stoptikzpicture
}

\testsubsection{modified labels}

{
\pgfplotsset{every axis label/.style={}}
\pgfplotsset{every axis x label/.style={
    at={(0.5,1)},
    above,
    yshift=+15pt}}
\pgfplotsset{every axis y label/.style={
    at={(1,0.5)},
    xshift=+35pt,
    rotate=90}}

\starttikzpicture
\startaxis[
	xlabel=$x$ axis,
	ylabel=$y$ axis,
	xmin=0,xmax=1,
	tickpos=right,
	xtick={-1.5,-1.25,...,1.5}]
\smallplotstest
\stopaxis
\stoptikzpicture
}

\starttikzpicture
\startaxis[
	xlabel=$x$ axis,
	ylabel=$y$ axis,
	xmin=0,xmax=1,
	tickpos=both,
	xtick={-1.5,-1.25,...,1.5}]
\smallplotstest
\stopaxis
\stoptikzpicture

\testsection{Tick label assigment tests}
\testsubsection{Using xticklabel and xtick}
\starttikzpicture
\startaxis[
	xtick={-1.5,-1,...,1.5},
	xticklabel={%
		\ifcase\ticknum	$-1\frac12$%
		\or				$-1$%
		\or				$-\frac12$%
		\or				$0$%
		\or				$\frac12$%
		\or				$1$%
		\or				$1\frac12$%
		\else			$\tick$%
		\fi
	}
]
\smallplotstest
\stopaxis
\stoptikzpicture

\testsubsection{Using xticklabels}%
\starttikzpicture
\startaxis[
	xtick={-1.5,-1,...,1.5},
	xticklabels={%
		$-1\frac 12$,
		$-1$,
		$-\frac 12$,
		$0$,
		$\frac 12$,
		$1$}
]
\smallplotstest
\stopaxis
\stoptikzpicture

\testsubsection{With xtick labels and commas by hand}
\starttikzpicture
\startaxis[
	xtick={-1.5,-1,...,1.5},
	xticklabels={%
		{-1,5},
		-1,
		{-0,5},
		0,
		{0,5},
		1,
		{1,5}}
]
\smallplotstest
\stopaxis
\stoptikzpicture

{
\testsubsection{Only with auto number formatting options; different for x and y}
%\tracingmacros=2\tracingcommands=2
\starttikzpicture
\startaxis[
	xtick={-1.5,-1,...,1.5},
	x tick label style={/pgf/number format/use comma},
	y tick label style={/pgf/number format/.cd,use comma,fixed zerofill,precision=3},
]
\smallplotstest
\stopaxis
\stoptikzpicture
}

\testsubsection{Using yticklabels in logplot}%
{
\def\tickformat#1{1e#1}%
\starttikzpicture
\startloglogaxis[
	ytick={1e-8,1e-7,1e-6,1e-5,1e-4,1e-3,1e-2,1e-1,1e0,1e1},
	yticklabels={%
		\tickformat{-8},
		\tickformat{-7},
		\tickformat{-6},
		\tickformat{-5},
		\tickformat{-4},
		\tickformat{-3},
		\tickformat{-2},
		\tickformat{-1},
		\tickformat{-0}}
]
\loglogtestplot
\stoploglogaxis
\stoptikzpicture
}

\testsection{Tick/Tick-Label placement log plots}
\testsubsection{ytickten}
\starttikzpicture
\startloglogaxis[
	%xmin=0.99e2,xmax=1e4,
	ytickten={-5,-4,-3.6,-3,-2,-1,0},
	yticklabel={
		\ifnum\ticknum=2	
			$\rightarrow$
		\else
			\axisdefaultticklabellog
		\fi
	}
]
\loglogtestplot
\stoploglogaxis
\stoptikzpicture

\testsubsection{ytick}
\starttikzpicture
\startloglogaxis[
	ytick={1e-5,1e-4,0.000251188643,1e-3,1e-2,1e-1,1e0},
]
\loglogtestplot
\stoploglogaxis
\stoptikzpicture

\testsubsection{extra y ticks}
\starttikzpicture
\startloglogaxis[
	extra y ticks={0.000251188643,5e-2},
]
\loglogtestplot
\stoploglogaxis
\stoptikzpicture

\testsubsection{extra y ticks and formatted label}
\starttikzpicture
\startloglogaxis[
	extra y ticks={0.000251188643,5e-2},
]
\loglogtestplot
\stoploglogaxis
\stoptikzpicture

\testsubsection{extra x and y ticks, linear plot}
\starttikzpicture
\startaxis[
	xmin=0,xmax=3,ymin=0,ymax=15,
	extra y ticks={2.71828},
	extra y tick labels={$e$},
	extra x ticks={2.2},
	extra x tick style={grid=major,/pgfplots/tick label style={rotate=90,anchor=east}},
	extra x tick labels={Cut}
]
	\addplot (\x,{exp(\x)});
	\addlegendentry{$e^x$}
\stopaxis
\stoptikzpicture
